function Login(GXUusername, GXUpassword, GXUtype) {
    var ISP_select;
    var username = document.querySelector("#edit_body > div:nth-child(3) > div.edit_loginBox.ui-resizable-autohide > form > input:nth-child(2)");
    var password = document.querySelector("#edit_body > div:nth-child(3) > div.edit_loginBox.ui-resizable-autohide > form > input:nth-child(3)");

    if (null != username) {
        username.value = GXUusername;
    }
    if (null != password) {
        password.value = GXUpassword;
    }
    if (GXUtype == "校园网") {
        ISP_select = document.querySelector("#edit_body > div:nth-child(3) > div.edit_loginBox.ui-resizable-autohide > select > option:nth-child(1)");
        ISP_select.selected = true;
    } else if (GXUtype == "中国移动") {
        ISP_select = document.querySelector("#edit_body > div:nth-child(3) > div.edit_loginBox.ui-resizable-autohide > select > option:nth-child(2)");
        ISP_select.selected = true;
    } else if (GXUtype == "中国联通") {
        ISP_select = document.querySelector("#edit_body > div:nth-child(3) > div.edit_loginBox.ui-resizable-autohide > select > option:nth-child(3)");
        ISP_select.selected = true;
    } else {
        ISP_select = document.querySelector("#edit_body > div:nth-child(3) > div.edit_loginBox.ui-resizable-autohide > select > option:nth-child(4)");
        ISP_select.selected = true;
    }
    var submitButton = document.querySelector("#edit_body > div:nth-child(3) > div.edit_loginBox.ui-resizable-autohide > form > input:nth-child(1)");
    if (null != submitButton) {
        submitButton.click();
    }
}

window.onload = function () {
    /**
     * 从chrome.storage取值
     */
    chrome.storage.sync.get({ "GXUusername": null, "GXUpassword": null, "GXUtype": null,"GXUstate":null }, function (n) {
        if (n.GXUstate == false){
            return;
        }
        Login(n.GXUusername, n.GXUpassword, n.GXUtype);
    });
}